
class HttpResponse<T> {
  final int code;
  final String message;
  final T? data;

  HttpResponse({required this.code, required this.message, this.data});

  factory HttpResponse.fromJson(
    Map<String, dynamic> json,
    T Function(dynamic json) fromJsonT,
  ) {
    return HttpResponse(
      code: json['code'] ?? 200,
      message: json['message'] ?? '',
      data: json['data'] != null ? fromJsonT(json['data']) : null,
    );
  }

  bool get isSuccess => code == 200;
}